import { ProductDetailResp, SkuCardPageResp } from "@/types/response";
import { apiClient } from ".";


export const skuService = {
  getHomepageList: async (pageNum: number, pageSize: number) => {
    const response = (await apiClient.get<SkuCardPageResp>('/product/sku-cards', { params: { pageNum, pageSize } }));
    if (response.data.code === 0 && 'data' in response.data) {
      return response.data.data.items
    }
    return []
  },

  getSkuDetail: async (skuId: number) => {
    const response = await apiClient.get<ProductDetailResp>("/product/product-detail", { params: { skuId } });
    if (response.data.code === 0 && 'data' in response.data) {
      return response.data.data;
    }
    return null;

  }
}

